package com.etonedu.meals.service;

import android.app.ActivityManager;
import android.app.Service;
import android.content.Intent;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.text.TextUtils;

import androidx.annotation.Nullable;

import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.etonedu.meals.BuildConfig;
import com.etonedu.meals.bean.MQTTRequest;
import com.etonedu.meals.bean.MessageBean;
import com.etonedu.meals.bean.Result;
import com.etonedu.meals.bean.TProduct;
import com.etonedu.meals.common.SPConst;
import com.etonedu.meals.enumeration.APICodeEnum;
import com.etonedu.meals.enumeration.MessageEnum;
import com.etonedu.meals.http.AppVersionUpdata;
import com.etonedu.meals.http.IGetUrl;
import com.etonedu.meals.http.LogReportUtils;
import com.etonedu.meals.http.ParamsUtils;
import com.etonedu.meals.http.Request;
import com.etonedu.meals.http.xutils.NewXUtilsRequest;
import com.etonedu.meals.http.xutils.NewXUtilsResponse;
import com.etonedu.meals.machine.DeviceManager;
import com.etonedu.meals.machine.DeviceUtils;
import com.etonedu.meals.utils.SharedPreferencesUtil;
import com.etonedu.meals.utils.Utils;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.qcloud.iot.common.Status;
import com.qcloud.iot.mqtt.TXMqttActionCallBack;
import com.qcloud.iot.mqtt.TXMqttConnection;
import com.qcloud.iot.mqtt.TXMqttConstants;
import com.qcloud.iot.util.AsymcSslUtils;

import org.eclipse.paho.client.mqttv3.IMqttToken;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.xutils.http.HttpMethod;
import org.xutils.x;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

public class DeamService extends Service {

    private int count;
    private Handler handler = new Handler();
    @Override
    public void onCreate() {
        super.onCreate();
        EventBus.getDefault().register(this);
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        onEvent("心跳");
        handler.removeCallbacks(runnable);
        handler.postDelayed(runnable,1000);
        SharedPreferencesUtil spu = SharedPreferencesUtil.getInstance(x.app());
        String psk = spu.getString(SPConst.DEVICE_PSK);
        if (Utils.isEmpty(psk)) {
            getPublicUrl();
        } else {
            connect();
        }
        return START_STICKY_COMPATIBILITY;
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
        if (txMqttConnection != null) {
            unSubscribeTopic();
            MQTTRequest mqttRequest = new MQTTRequest("connect", requestID.getAndIncrement());
            txMqttConnection.disConnect(mqttRequest);
        }
    }

    @Subscribe
    public void refresh(MessageEnum messageEnum) {
        String type = messageEnum.getType();
        if (MessageEnum.ECB_2027.getType().equals(type)) {


            String time1 = Utils.timestamp2String1(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss");
            String pagek = this.getClass().getPackage().getName();
            LogReportUtils.log("收到升级通知", pagek, Utils.getLineInfo(), time1);

            SharedPreferencesUtil spu = SharedPreferencesUtil.getInstance(x.app());
            String token = spu.getString(SPConst.TOKEN);
            AppVersionUpdata.getPublicUrl(token);

        }
    }

    @Subscribe
    public void onEvent(String msg) {
        if ("心跳".equals(msg)) {
            count++;
            String time1 = Utils.timestamp2String1(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss");
            String pagek = this.getClass().getPackage().getName();
//            LogReportUtils.log("心跳", pagek, Utils.getLineInfo(), time1);

            getSystemMemory();

            connect();
            if (count >= 5) {
                count = 0;
                LogUtils.e("心跳");
                SharedPreferencesUtil spu = SharedPreferencesUtil.getInstance(this);
                String token = spu.getString(SPConst.TOKEN);
                LogReportUtils.getPublicUrl(token);

                String screen = spu.getString(SPConst.OPERATION_SRCEEN);

                LogUtils.e("屏幕 screen = " + screen);

                LogReportUtils.log("5分钟发送一次心跳 屏幕 screen = " + screen, pagek, Utils.getLineInfo(), time1);

                if (!TextUtils.isEmpty(screen)) {
                    if ("0".equals(screen)) {
                        LogReportUtils.getPublicStateUrl("1");
                    } else {
                        LogReportUtils.getPublicStateUrl("3");
                    }
                } else {
                    LogReportUtils.getPublicStateUrl("1");
                }
            }

        } else if ("插入sim卡".equals(msg)) {
            LogUtils.e("插入sim卡");
            handler.removeCallbacks(runnable);
        } else if ("拔出sim卡".equals(msg)) {
            LogUtils.e("拔出sim卡");
            handler.postDelayed(runnable,1000);
        }
    }

    private void getSystemMemory() {
        final ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
        ActivityManager.MemoryInfo info = new ActivityManager.MemoryInfo();
        activityManager.getMemoryInfo(info);
        Runtime rt = Runtime.getRuntime();
        long maxMemory = rt.maxMemory();

        // 系统剩余内存
        long availMem = info.availMem >> 10;
        // 系统是否处于低内存运行
        boolean isLowMem = info.lowMemory;
        // 当系统剩余内存低于
        long threshold = info.threshold >> 10;

        String time1 = Utils.timestamp2String1(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss");
        String pagek = this.getClass().getPackage().getName();

        String content = "maxMemory:" + (maxMemory / (1024 * 1024)) +"M"+ "   "+
                ",系统剩余内存:" + (availMem/1024)  + "M" + "  " + ",系统是否处于低内存运行：" + isLowMem + "  "+
                ",当系统剩余内存低于" + (threshold / 1024) + "M时就看成低内存运行";

        LogReportUtils.log(content,pagek,Utils.getLineInfo(),time1);


    }

    private Runnable runnable = new Runnable() {
        @Override
        public void run() {
            String pakeName = "com.etonedu.general";
            if (!Utils.isTopActivity(pakeName)) {
                startActivity();

            }

            handler.postDelayed(this,20 * 1000);
        }
    };

    private void startActivity() {
        try {
            Intent intent = new Intent();
//            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//            ComponentName cn = new ComponentName("com.etonedu.general", "com.etonedu.general.ui.MainActivity");
//            intent.setComponent(cn);
            intent.setClassName("com.etonedu.general", "com.etonedu.general.ui.MainActivity");
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

            startActivity(intent);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /***********************************腾讯云推送**************************************/
    private void getPublicUrl() {
        SharedPreferencesUtil spu = SharedPreferencesUtil.getInstance(x.app());
        String psk = spu.getString(SPConst.DEVICE_PSK);
        String token = spu.getString(SPConst.TOKEN);
        String apiCode = APICodeEnum.agw30161044.getApiCode();
        String type = spu.getString(SPConst.ENVIRONMENT);
//        String environType = EnvironmentType.TEST01.getType();

        String url = spu.getString(SPConst.AGW_30161044);
        if (!Utils.isEmpty(url)) {
            getData(url,token);
            return;
        }

       Request request = new Request();
        request.getPublicUrl(apiCode,type);
        request.setGetUrl(new IGetUrl() {
            @Override
            public void success(String content) {
                spu.setString(SPConst.AGW_30161044,content);
                getData(content,token);
                LogUtils.e("content = "+content);
            }

            @Override
            public void fail(String content) {
                LogUtils.e("content = "+content);
            }
        });
    }

    private void getData(String url , String token) {
        SharedPreferencesUtil spu = SharedPreferencesUtil.getInstance(x.app());
        String apiCode = APICodeEnum.agw30161044.getApiCode();
        String header = ParamsUtils.getHeader(apiCode, token);

        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("deviceCode", Utils.getDevCode());
        hashMap.put("productId",BuildConfig.ProductId);
        Gson gson = new Gson();
        String json = gson.toJson(hashMap);

        String data = ParamsUtils.getEncrypt(apiCode,json);

        String data1 = ParamsUtils.getParams(apiCode,data);

        NewXUtilsRequest request = new NewXUtilsRequest(header, data1);
        request.requet(url, apiCode, HttpMethod.POST, new NewXUtilsResponse(){

            @Override
            public void response(String type, String result) {
                LogUtils.e("result = "+result);

                Type typeToken = new TypeToken<Result>() {
                }.getType();
                Gson gson = new Gson();
                Result r = gson.fromJson(result, typeToken);

                String data = r.getData();

                if (!Utils.isEmpty(data)) {
                    String deData = ParamsUtils.getDecrypt(apiCode,data);
                    LogUtils.json(deData);

                    Type type1 = new TypeToken<TProduct>(){}.getType();
                    TProduct tProduct = gson.fromJson(deData,type1);
                    String psk = tProduct.getDevicePsk();
                    LogUtils.e("psk = "+psk);
                    spu.setString(SPConst.DEVICE_PSK,psk);
                    connect();
                }
            }

            @Override
            public void error(String type, String msg) {
                LogUtils.e(type,msg);
            }
        });
    }

    /**
     * 请求ID
     */
    private static AtomicInteger requestID = new AtomicInteger(0);
    private TXMqttConnection txMqttConnection;
    private String mBrokerURL = "ssl://iotcloud-mqtt.gz.tencentdevices.com:8883";
    private void connect() {

        if (txMqttConnection !=null){
            String time1 = Utils.timestamp2String1(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss");
            String pagek = this.getClass().getPackage().getName();

            String content = "";


            TXMqttConstants.ConnectStatus connectStatus  = txMqttConnection.getConnectStatus();

            if (connectStatus==TXMqttConstants.ConnectStatus.kConnected){
                content = "设备已连接";
                LogReportUtils.log(content,pagek,Utils.getLineInfo(),time1);
                return;
            }
            if (connectStatus== TXMqttConstants.ConnectStatus.kConnecting){
                content = "设备已连接";
                LogReportUtils.log(content,pagek,Utils.getLineInfo(),time1);
                return;
            }

            MQTTRequest mqttRequest = new MQTTRequest("disconnect", requestID.getAndIncrement());
            txMqttConnection.disConnect(mqttRequest);
        }

        SharedPreferencesUtil spu = SharedPreferencesUtil.getInstance(x.app());
        String psk = spu.getString(SPConst.DEVICE_PSK);
        String mDevName = Utils.getDevCode();
        txMqttConnection = new TXMqttConnection(this,mBrokerURL,
                BuildConfig.ProductId,mDevName,psk,null,null,new TXMqttActionCallBack(){

            @Override
            public void onConnectCompleted(Status status, boolean reconnect, Object userContext, String msg) {
                String userContextInfo = "";
                if (userContext instanceof MQTTRequest) {
                    userContextInfo = userContext.toString();
                }
                String time1 = Utils.timestamp2String1(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss");
                String pagek = this.getClass().getPackage().getName();
                String logInfo = String.format("onConnectCompleted, status[%s], reconnect[%b], userContext[%s], msg[%s]",
                        status.name(), reconnect, userContextInfo, msg);
                LogReportUtils.log(logInfo,pagek,Utils.getLineInfo(),time1);
                LogUtils.e("msg = "+logInfo);
                subscribeTopic();
            }

            @Override
            public void onConnectionLost(Throwable cause) {
                LogUtils.e("cause.getMessage() = "+cause.getMessage());
                ToastUtils.showShort(cause.getMessage());
                String time1 = Utils.timestamp2String1(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss");
                String pagek = this.getClass().getPackage().getName();

                LogReportUtils.log(cause.getMessage(),pagek,Utils.getLineInfo(),time1);
            }

            @Override
            public void onDisconnectCompleted(Status status, Object userContext, String msg) {
                String userContextInfo = "";
                if (userContext instanceof MQTTRequest) {
                    userContextInfo = userContext.toString();
                }
                String logInfo = String.format("onDisconnectCompleted, status[%s], userContext[%s], msg[%s]",
                        status.name(), userContextInfo, msg);
                String time1 = Utils.timestamp2String1(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss");
                String pagek = this.getClass().getPackage().getName();

                LogReportUtils.log(logInfo,pagek,Utils.getLineInfo(),time1);
                LogUtils.e("msg = "+logInfo);
            }

            @Override
            public void onSubscribeCompleted(Status status, IMqttToken token, Object userContext, String msg) {
                String userContextInfo = "";
                if (userContext instanceof MQTTRequest) {
                    userContextInfo = userContext.toString();
                }
                String logInfo = String.format("onSubscribeCompleted, status[%s], reconnect[%b], userContext[%s], msg[%s]",
                        status.name(), token.getTopics()[0], userContextInfo, msg);
                LogUtils.e("msg = "+logInfo);
                String time1 = Utils.timestamp2String1(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss");
                String pagek = this.getClass().getPackage().getName();

                LogReportUtils.log(logInfo,pagek,Utils.getLineInfo(),time1);
            }

            @Override
            public void onUnSubscribeCompleted(Status status, IMqttToken token, Object userContext, String msg) {
                String userContextInfo = "";
                if (userContext instanceof MQTTRequest) {
                    userContextInfo = userContext.toString();
                }
                String logInfo = String.format("onUnSubscribeCompleted, status[%s], reconnect[%b], userContext[%s], msg[%s]",
                        status.name(), token.getTopics()[0], userContextInfo, msg);
                LogUtils.e("msg = "+logInfo);
                String time1 = Utils.timestamp2String1(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss");
                String pagek = this.getClass().getPackage().getName();

                LogReportUtils.log(logInfo,pagek,Utils.getLineInfo(),time1);
            }

            @Override
            public void onMessageReceived(String topic, MqttMessage message) {
                LogUtils.e(topic+","+message.toString());
                String time1 = Utils.timestamp2String1(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss");
                String pagek = this.getClass().getPackage().getName();

                LogReportUtils.log(message.toString(),pagek,Utils.getLineInfo(),time1);
                message(message.toString());
            }
        });

        MqttConnectOptions options = new MqttConnectOptions();
        options.setConnectionTimeout(8);
        options.setKeepAliveInterval(240);
        options.setAutomaticReconnect(true);
        options.setSocketFactory(AsymcSslUtils.getSocketFactory());

        MQTTRequest mqttRequest = new MQTTRequest("connect", requestID.getAndIncrement());


        txMqttConnection.connect(options,mqttRequest);
    }

    /**
     * 订阅主题
     *
     */
    private String mTestTopic = "%s/%s/data";
    private void subscribeTopic() {

        // 主题
        String topic = String.format(mTestTopic,BuildConfig.ProductId,Utils.getDevCode());
        LogUtils.e("topic = "+topic);
        // QOS等级
        int qos = TXMqttConstants.QOS1;
        // 用户上下文（请求实例）
        MQTTRequest mqttRequest = new MQTTRequest("subscribeTopic", requestID.getAndIncrement());

        LogUtils.e("sub topic is " + topic);

        // 订阅主题
        txMqttConnection.subscribe(topic, qos, mqttRequest);

    }

    /**
     * 取消订阅主题
     *
     */
    private void unSubscribeTopic() {
        // 主题
        String topic = String.format(mTestTopic, BuildConfig.ProductId,Utils.getDevCode());
        // 用户上下文（请求实例）
        MQTTRequest mqttRequest = new MQTTRequest("unSubscribeTopic", requestID.getAndIncrement());
        LogUtils.e("Start to unSubscribe" + topic);
        if (txMqttConnection!=null){
            // 取消订阅主题
            txMqttConnection.unSubscribe(topic, mqttRequest);
        }

    }

    private void message(String customContent) {
        try {
            Gson gson = new Gson();
            Type type = new TypeToken<MessageBean>() {
            }.getType();
            MessageBean messageBean = gson.fromJson(customContent, type);

            String time1 = Utils.timestamp2String1(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss");
            String pagek = "com.etonedu.general.edu.receiver";
            LogReportUtils.log("收到推送:" + customContent, pagek, Utils.getLineInfo(), time1);

            String msgType = messageBean.getType();
            if (MessageEnum.ECB_1001.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_1001);

            } else if (MessageEnum.ECB_1002.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_1002);

            } else if (MessageEnum.ECB_1003.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_1003);

            } else if (MessageEnum.ECB_1004.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_1004);
                LogReportUtils.logReportPublicUrl(messageBean.getLogId(), "12", "1", "模版切换");

            } else if (MessageEnum.ECB_1005.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_1005);

            } else if (MessageEnum.ECB_1006.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_1006);

            } else if (MessageEnum.ECB_1007.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_1007);

            } else if (MessageEnum.ECB_1008.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_1008);

            } else if (MessageEnum.ECB_1009.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_1009);

            } else if (MessageEnum.ECB_1010.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_1010);

            } else if (MessageEnum.ECB_1011.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_1011);

            } else if (MessageEnum.ECB_1012.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_1012);

            } else if (MessageEnum.ECB_1013.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_1013);

            } else if (MessageEnum.ECB_1014.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_1014);

            } else if (MessageEnum.ECB_1015.getType().equals(msgType)) {

                List<String> list = messageBean.getUserIds();
                messageBean.getType();
                String userIds = gson.toJson(list);
                LogUtils.e("userIds = " + userIds);
                MessageEnum messageEnum = MessageEnum.ECB_1015;
                messageEnum.setDesc(userIds);
                messageEnum.setOpType(messageBean.getOpType());
                EventBus.getDefault().post(messageEnum);

            } else if (MessageEnum.ECB_1016.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_1016);

            } else if (MessageEnum.ECB_1017.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_1017);

            } else if (MessageEnum.ECB_2015.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_2015);
                LogReportUtils.logReportPublicUrl(messageBean.getLogId(), "1", "1", "开关机时间设置");

            } else if (MessageEnum.ECB_2016.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_2016);
                LogReportUtils.logReportPublicUrl(messageBean.getLogId(), "14", "1", "开关屏时间设置");

            } else if (MessageEnum.ECB_2017.getType().equals(msgType)) {

                LogReportUtils.logReportPublicUrl(messageBean.getLogId(), "2", "1", "手动关机");
                LogReportUtils.getPublicStateUrl("2");

                EventBus.getDefault().post(MessageEnum.ECB_2017);

            } else if (MessageEnum.ECB_2018.getType().equals(msgType)) {

                int sdkVersion = Utils.getAndroidSDKVersion();

                if (sdkVersion <= Build.VERSION_CODES.LOLLIPOP_MR1) {
                    DeviceUtils.setMachineScreen(true);
                    DeviceUtils.timerSwitchOnScreen();
                    DeviceUtils.timerSwitchOnScreenAndroid5();
                } else {
                    DeviceManager.getInstance().turnOnBackLight();
                }

                DeviceUtils.openMacineScreen();

                EventBus.getDefault().post(MessageEnum.ECB_2018);

                SharedPreferencesUtil spu = SharedPreferencesUtil.getInstance(x.app());
                spu.setString(SPConst.OPERATION_SRCEEN, "0");

                LogReportUtils.logReportPublicUrl(messageBean.getLogId(), "3", "1", "手动开屏");
                LogReportUtils.getPublicStateUrl("1");

            } else if (MessageEnum.ECB_2019.getType().equals(msgType)) {
                int sdkVersion = Utils.getAndroidSDKVersion();

                if (sdkVersion <= Build.VERSION_CODES.LOLLIPOP_MR1) {
                    DeviceUtils.setMachineScreen(false);
                    DeviceUtils.timerSwitchOffScreen();
                    DeviceUtils.timerSwitchOffScreenAndroid5();
                    EventBus.getDefault().post(MessageEnum.ECB_2019);
                } else {
                    DeviceManager.getInstance().turnOffBackLight();
                }

                DeviceUtils.closeMacineScreen();

                SharedPreferencesUtil spu = SharedPreferencesUtil.getInstance(x.app());
                spu.setString(SPConst.OPERATION_SRCEEN, "1");

                LogReportUtils.logReportPublicUrl(messageBean.getLogId(), "4", "1", "手动关屏");

                LogReportUtils.getPublicStateUrl("3");

            } else if (MessageEnum.ECB_2020.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_2020);
                LogReportUtils.logReportPublicUrl(messageBean.getLogId(), "13", "1", "截屏");

            } else if (MessageEnum.ECB_2021.getType().equals(msgType)) {// 亮度

                try {
                    String value = messageBean.getLuminance();
                    Utils.setScreenBritness(x.app(), Integer.valueOf(value));
                    LogReportUtils.logReportPublicUrl(messageBean.getLogId(), "9", "1", "设置亮度");
                } catch (Exception e) {
                    e.printStackTrace();
                }
                EventBus.getDefault().post(MessageEnum.ECB_2021);

            } else if (MessageEnum.ECB_2022.getType().equals(msgType)) {// 音量

                try {
                    String value = messageBean.getVolume();
                    Utils.setStreamVolume(x.app(), Integer.valueOf(value));
                    LogReportUtils.logReportPublicUrl(messageBean.getLogId(), "10", "1", "设置音量");
                } catch (Exception e) {
                    e.printStackTrace();
                }
                EventBus.getDefault().post(MessageEnum.ECB_2022);

            } else if (MessageEnum.ECB_2023.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_2023);
                LogReportUtils.logReportPublicUrl(messageBean.getLogId(), "15", "1", "考勤时间设置");

            } else if (MessageEnum.ECB_2024.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_2024);

            } else if (MessageEnum.ECB_2025.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_2025);
                LogReportUtils.stateReportPublicUrl();

            } else if (MessageEnum.ECB_2026.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_2026);

            } else if (MessageEnum.ECB_2027.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_2027);

            } else if (MessageEnum.ECB_2028.getType().equals(msgType)) {

                EventBus.getDefault().post(MessageEnum.ECB_2028);

            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}